class Witness < ActiveRecord::Base

  belongs_to :character
  belongs_to :raid_event

  def value
    return raid_event.event.convert_raw_witness(self).to_f
  end
  
  def raw_value
    if self['raw_value']
      return self['raw_value'].to_f
    else
      return self['raw_value'] = raid_event.event.calculate_raw_witness(self).to_f
    end
  end
  
  def raw_value=(raw_value)
    if raw_value != self['raw_value']
      self['raw_value'] = raw_value
      self['value'] = nil
    end
  end
end
